package com.yyge.web.servlet;

import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet(urlPatterns={"/setting"})
public class IndexServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doGet(req, resp);
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");

        PrintWriter out=resp.getWriter();
       out.write("<html>");
        out.write("<head>");
        out.write("<meta charset=\"utf-8\" />");
        out.write("<title>手撸Servlet</title>");
        out.write("<style>");
        out.write("li{color:red;font-weight:bold;}");
        out.write("</style>");
        out.write("</head>");
        out.write("<body>");

        String[] names = {"格温","劫","格雷福斯","亚索","永恩"};
        out.write("<ul>");
        for (String name : names) {
            out.write("<li>" + name + "</li>");
        }
        out.write("</ul>");
        out.write("</body>");
        out.write("</html>");
        // 刷新缓存
        out.flush();
        // 关闭流
        out.close();
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
/**
 * urlPatterns: 代表用户在浏览器中输入的url地址，用于访问当前的servlet
 */

}
